package com.zhentao.controller;

import com.zhentao.dto.FaceLoginRequest;
import com.zhentao.dto.FaceRegisterRequest;
import com.zhentao.pojo.SysUser;
import com.zhentao.service.FaceAuthService;
import com.zhentao.service.SysUserService;
import com.zhentao.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("customsLogin")
public class customsLogin {
    @Autowired
    private SysUserService userService;
    @Autowired
    private FaceAuthService faceAuthService;
    @PostMapping(value = "/login")
    public Result login(@RequestBody SysUser user) {
        return userService.login(user);
    }
    /**
     * 人脸登录
     */
    @PostMapping(value = "/faceLogin")
    public Result faceLogin(@RequestBody FaceLoginRequest request) {
        return faceAuthService.faceLogin(request);
    }

    /**
     * 传统用户注册
     */
    @PostMapping(value = "/save")
    public Result save(@RequestBody SysUser user) {
        return userService.saveUser(user);
    }

    /**
     * 人脸注册
     */
    @PostMapping(value = "/faceRegister")
    public Result faceRegister(@RequestBody FaceRegisterRequest request) {
        return faceAuthService.faceRegister(request);
    }
}
